<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="common/common :: common_head(~{::title},~{::link},~{})">
    <link rel="shortcut icon" th:href="@{/icons/favicon.ico}"/>
    <title>建设用地微服务</title>
</head>




<body>
<!--显示loding区域-->
<DIV id=loading-mask></DIV>
<DIV id=loading>
    <DIV class=loading-indicator>
        <IMG style="MARGIN-RIGHT: 8px"
             height=32
             src="./icons/image/ajax1.gif"
             width=36 align=absMiddle>正在初始化,请稍等...</DIV>
</DIV>

<a href="#" onclick="javascript:endIeStatus();" id="endIeStatus" style="display: none;" />

<!-- 根路径 -->
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    ctxPath = /*[[@{/}]]*/ '';
    /*]]>*/



    console.info(ctxPath);
</script>
<script type="text/javascript">
    var mainTabs;
    var demoStore;
    var devStore;
    var bizMenuStore;
    var menuModel = Ext.create("Ext.data.TreeModel",{
        fields:[
            {text:'text',type: 'string' },
            {path:'url',type: 'string' },
            {icon:'icon',type: 'string'},
            {id:'id',type:'string'},
            {desc:"desc",type: 'string'}
        ]
    });
    Ext.onReady(function() {

        devStore = Ext.create('Ext.data.TreeStore', {
            model:menuModel,
            /**自动加载*/
            autoLoad:true,
            root: {
                expanded: true,
                text: 'All',
            },
            data: {
                "children": [
                    {
                        "text": "系统预制图标",
                        "icon": "./icons/Images.png",
                        "leaf": true,
                        "url":"common/icons.html",
                        "id": "0801"
                    }
                ]
            }
            // proxy :{
            //     type: 'ajax',
            //     url: '/icons/data/devmenu.json'
            // }
        });

        bizMenuStore = Ext.create('Ext.data.TreeStore', {
            model:menuModel,
            /**自动加载*/
            autoLoad:true,
            root: {
                expanded: true,
                text: 'All',
            },
            data:{
                "children": [
                    {
                        "text": "版本配置",
                        "leaf": false,
                        "id": "09",
                        "expanded":true,
                        "children": [
                            {
                                "text": "分析版本配置",
                                "icon": "./icons/Application_form.png",
                                "leaf": true,
                                "url": "analyse/profile",
                                "id": "0901"
                            },
                            {
                                "text": "平差版本配置",
                                "icon": "./icons/Calculator.png",
                                "leaf": true,
                                "url": "adjust/version",
                                "id": "0903"
                            },
                            {
                                "text": "地类编码配置",
                                "icon": "./icons/Bullet_edit.png",
                                "leaf": true,
                                "url": "dlbmVersion/profile",
                                "id": "0904"
                            }
                        ]
                    },{
                        "text": "系统日志",
                        "leaf": false,
                        "id": "10",
                        "expanded":true,
                        "children": [
                            {
                                "text": "分析日志",
                                "icon": "./icons/Text_columns.png",
                                "leaf": true,
                                "url": "analyseFxrz/profile",
                                "id": "1001"
                            },
                            {
                                "text": "案卷锁定记录",
                                "icon": "./icons/Lock.png",
                                "leaf": true,
                                "url": "jsydlock/profile",
                                "id": "1002"
                            }
                        ]
                    },{
                        "text": "实时案卷锁定",
                        "leaf": false,
                        "id": "11",
                        "expanded":true,
                        "children": [
                            {
                                "text": "分析日志",
                                "icon": "./icons/Lock.png",
                                "leaf": true,
                                "url": "redislock/profile",
                                "id": "1101"
                            }
                        ]
                    },{
                        "text": "数据服务",
                        "leaf": false,
                        "id": "11",
                        "expanded":true,
                        "children": [
                            {
                                "text": "统计服务",
                                "icon": "./icons/application_edit.png",
                                "leaf": true,
                                "url": "statistics/profile",
                                "id": "0902"
                            },
                            {
                                "text": "统计执行记录",
                                "icon": "./icons/Paste_plain.png",
                                "leaf": true,
                                "url": "logStatistics/profile",
                                "id": "1003"
                            },
                            {
                                "text": "数据查询",
                                "icon": "./icons/Text_columns.png",
                                "leaf": true,
                                "url": "udp/profile",
                                "id": "1101"
                            },
                            {
                                "text": "后置统计",
                                "icon": "./icons/application_home.png",
                                "leaf": true,
                                "url": "postAnalyse/profile",
                                "id": "1103"
                            }
                        ]
                    }]
            }
        });

        mainTabs = new Ext.TabPanel({
            region:'center',
            activeTab:0,
            id:'mainTabs',
            enableTabScroll:true,
            plugins: new Ext.ux.TabCloseMenu(),
            frame:false,
            border:false,
            items:[{
                title:"<img align='top' class='IEPNG' src='./icons/user.png'/>我的工作台",
                listeners: {activate: function(){Ext.getCmp('centerPanel').setTitle('示例平台 -> 欢迎页');}},
                html:"<iframe name='mainFrame'  src='tj' scrolling='auto' frameborder='0' width='100%' height='100%' ></iframe>"
            }]
        });

        var accordion = Ext.create("Ext.panel.Panel", {
            title: "菜单导航",
            layout: "accordion", //设置为手风琴布局
            layoutConfig: {
                animate: true
            },
            width: 200,
            minWidth: 90,
            region: "west", //设置方位
            split: true,
            collapsible: true,
            items: [{
                title: "业务功能",
                iconCls: "Arrowrefresh",
                rootVisible: false,
                xtype: 'treepanel',
                store: bizMenuStore,
                width:200,//这里一定要设置好宽度，否则不显示
                split:true,//可以自己调整其大小
                expanded:true,
                collapsible:true,//可以折叠
                listeners:{
                    itemclick:menuClick
                }
            }
                ,{
                    title: "开发人员",
                    iconCls: "Cog",
                    rootVisible: false,
                    xtype: 'treepanel',
                    store: devStore,//添加树状图
                    expanded:true,
                    width:200,//这里一定要设置好宽度，否则不显示
                    split:true,//可以自己调整其大小
                    collapsible:true,//可以折叠
                    listeners:{
                        itemclick:menuClick
                    }
                }]
        });

        new Ext.Viewport({
            title: "示例平台",
            layout: "border", //这里是（border）边界布局
            defaults: {
                bodyStyle: "background-color: #FFFFFF;",
                frame: true
            },
            items: [
                accordion, //这里是（accordion）手风琴布局
                // {
                //     region: "north",
                //     height: 80,
                //     title: '吉奥示例平台',
                //     collapsible: false
                // }
                // ,
                {
                    region: "center",
                    id:'centerPanel',
                    collapsible: false,
                    layout: 'fit',
                    autoScroll:false,
                    frame: false,
                    title: '我的工作台',
                    items:[mainTabs]
                },{
                    region:'south',
                    split:false,//可以自己调整其大小
                    collapsible:false,//可以折叠
                    title:'欢迎您,开发人员!!',
                    frame:false,
                    border:false
                }
            ]
        });
    });
    /**
     * 响应树节点单击事件
     */
    function addTab(url,name,menuid,pathCh,icon){
        if(Ext.isEmpty(icon)){
            icon = 's.gif';
        }
        var id = "tab_id_" + menuid;
        if(url == '#' || url == ''){
            //Ext.Msg.alert('提示', '此菜单还没有指定请求地址,无法为您打开页面.');
            return;
        }else{
            var index = url.indexOf('.do');
            if(index != -1)
                url = url + '&menuid4Log=' + menuid;
            var n = mainTabs.getComponent(id);
            if (!n) {
                // 如果对centerPanel进行遮罩,则可以出现阴影mainTabs
                //Ext.getCmp('centerPanel').getEl().mask('<span style=font-size:12>正在加载页面,请稍等...</span>', 'x-mask-loading');
                // document.getElementById('endIeStatus').click();//解决Iframe IE加载不完全的问题
                // 兼容IE和FF触发.click()函数
                var endIeStatus = document.getElementById("endIeStatus");
                if(document.createEvent){
                    var ev = document.createEvent('HTMLEvents');
                    ev.initEvent('click', false, true);
                    endIeStatus.dispatchEvent(ev);
                }
                else endIeStatus.click();
                n = mainTabs.add({
                    id:id,
                    title:"<img align='top' class='IEPNG' src='"+icon + "'/>" + name,
                    closable:true,
                    layout:'fit',
                    listeners: {activate: function(){Ext.getCmp('centerPanel').setTitle(pathCh)}},
                    html:'<iframe scrolling="auto" frameborder="0" width="100%" height="100%" src='+url+'></iframe>'
                });
            }
            mainTabs.setActiveTab(n);
        }
    }

    // 解决Iframe IE加载不完全的问题
    function endIeStatus(){}

    Ext.EventManager.on(window, 'load', function(){
        setTimeout(
            function() {
                Ext.get('loading').remove();
                Ext.get('loading-mask').fadeOut({remove:true});
            }, 200);
    });

    /**
     * 取消阴影(当子页面加载完成后通过parent.XXXX来调用)
     */
    function unmaskCenterPanel(){
        // 如果对centerPanel进行遮罩,则可以出现阴影
        Ext.getCmp('centerPanel').getEl().unmask();
    }

    function menuClick( node, event ) {
        var itemData = event.data;
        addTab(itemData.url,itemData.text,itemData.id,'示例平台 -> '+itemData.text,itemData.icon);
        console.log( event.data );
    };
</script>
</body>
</html>